package com.multicampus.minishop.util;

import java.sql.Connection;

import javax.naming.InitialContext;
import javax.sql.DataSource;

public class DBUtil {
	private static DataSource dataSource;
	static {
		try{
			InitialContext cxt=new InitialContext();
			dataSource=(DataSource)cxt.lookup("java:comp/env/jdbc/myoracle");
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	public static Connection getConnection(){
		Connection conn = null;
		try{
			return dataSource.getConnection();
		}catch(Exception e){
			e.printStackTrace();
			throw new RuntimeException(e);
		}

	}
	
//	public static Connection getConnection() {
//		Connection con = null;
//		try {
//			Class.forName("oracle.jdbc.driver.OracleDriver");
//			String url = "jdbc:oracle:thin:@localhost:1521:xe";
//			con = DriverManager.getConnection(url, "hr", "hr");
//			
//		} catch (Exception e) {
//			// TODO: handle exception
//			e.printStackTrace();
//		}
//		return con;
//	}
	
	

}

